package com.ams.thread.lesson2;

import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author： 乐哥聊编程(全平台同号)
 */
@Slf4j
public class Example8 {

    public static void main(String[] args) {
        Thread suspendThread = new Thread(new SuspendThread());
        Thread normalThread = new Thread(new NormalThread());
        suspendThread.start();
        ThreadUtil.sleep(5000);
        normalThread.start();
        suspendThread.suspend();
    }

    static class SuspendThread implements Runnable {
        @Override
        public void run() {
            synchronized (Example8.class){
                while (true){
                    ThreadUtil.sleep(2000);
                    log.info("SuspendThread running");
                }
            }
        }
    }
    static class NormalThread implements Runnable {
        @Override
        public void run() {
            synchronized (Example8.class){
                log.info("NormalThread 获取锁");
            }
        }
    }
}
